package com.lightheart.sphr.xiaobinggan.customchannel

import android.content.Intent
import android.view.View
import com.lightheart.sphr.xiaobinggan.R
import com.lightheart.sphr.xiaobinggan.base.BaseActivity
import com.lightheart.sphr.xiaobinggan.module.home.presenter.HomePresenter
import kotlinx.android.synthetic.main.common_toolbar.*

/*****
 * void setStyleAdapter(StyleAdapter styleAdapter)  设置适配器，最主要的方法，可实现数据填充，自定义样式
 * void setInsertRecommendPosition(int recommendPosition) 设置插入到我的频道的位置，如果不设置，默认从尾部插入
 * void setChannelFixedCount(int channelFixedCount)  设置固定频道数量
 * boolean isChange()  频道序列是否发生变化
 * List getMyChannel()  获取我的频道内容
 * List<List> getOtherChannel()  获取其他频道内容
 * void setOnChannelListener(OnChannelListener onChannelListener)  设置监听器
 *
 *
 * void channelItemClick(int position, Channel channel)   频道点击回调
 * void channelEditFinish(List channelList) 频道编辑完成回调
 * void channelEditStart()  开始编辑频道
 * void channelEditStateItemClick(int position, Channel channel) 编辑状态下频道点击
 *
 * github 地址
 * https://github.com/chengzhicao/ChannelView
 */
class ChannelActivity : BaseActivity<HomePresenter>() , ChannelDialog.ChannelListener{

    override fun getLayoutId() = R.layout.activity_channel

    private var mChannelDialog: ChannelDialog? = null

    override fun initInjector() {
    }

    override fun initView() {
        initToolbar(common_toolbar, common_toolbar_title_tv, bt_sub, R.string.channel, true, R.string.register)
        if (mChannelDialog == null) {
            mChannelDialog = ChannelDialog(this)
            mChannelDialog?.setCancelable(false)
            mChannelDialog?.setCanceledOnTouchOutside(false)
            mChannelDialog?.setOnClickChannelListener(this)
        }
        bt_sub.setOnClickListener {
            if (mChannelDialog?.isShowing == false) {
                mChannelDialog?.show()
            }
        }
    }

    fun intoChannelView(view: View) {
        startActivity(Intent(this, ChannelViewActivity::class.java))
    }

    fun intoCustomChannelView(view: View) {
        startActivity(Intent(this, CustomChannelActivity::class.java))
    }

    override fun onClickSure() {

    }

    override fun showHomeAsUp(): Boolean {
        return true
    }
}